//
//  DianzanViewController.m
//  AnimationDemo
//
//  Created by Jiaozl 2018 on 2018/9/14.
//  Copyright © 2018年 Jiaozl. All rights reserved.
//

#import "DianzanViewController.h"
#import "LikeButton.h"
@interface DianzanViewController ()

@end

@implementation DianzanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self addLikebutton];
}

#pragma mark - 点赞

- (void) addLikebutton {
    LikeButton *likebtn = [[LikeButton alloc] initWithFrame:CGRectMake(80, 80, 30, 30)];
    [self.view addSubview:likebtn];
    [likebtn setImage:[UIImage imageNamed:@"dislike"] forState:UIControlStateNormal];
    [likebtn setImage:[UIImage imageNamed:@"liek_orange"] forState:UIControlStateSelected];
    [likebtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)btnClick:(UIButton *)button{
    
    if (!button.selected) { // 点赞
        NSLog(@"点赞");
    }else{ // 取消点赞
        NSLog(@"取消赞");
    }
    
    button.selected = !button.selected;
}




@end
